package com.ll.domain.jj.convert;

import com.alibaba.fastjson.JSONObject;
import com.ll.app.api.jj.JJProjectDTO;
import com.ll.app.api.jj.JJProjectRecordDTO;
import com.ll.base.util.ScalarUtil;
import com.ll.dal.po.JJProjectPO;
import org.springframework.beans.BeanUtils;

import java.util.List;

/**
 * 转换类
 *
 * @author WuHen
 * @date 2021/10/17 17:26
 **/
public class JJProjectConvert {

    public static JJProjectDTO PO2DTO(JJProjectPO po){
        JJProjectDTO dto = new JJProjectDTO();
        BeanUtils.copyProperties(po, dto);
        if(ScalarUtil.isNotEmpty(po.getRecord())){
            List<JJProjectRecordDTO> recordDTOS = JSONObject.parseArray(po.getRecord(), JJProjectRecordDTO.class);
            dto.setRecordList(recordDTOS);
        }
        dto.setStatusIndex(po.getStatus().ordinal());
        return dto;
    }
}
